# -*- coding:utf-8 -*-
from service.ansible_operation import AnsibleApi

#加快ansible执行方法
def ansible_shll(host,module,args):
    run_ansible = AnsibleApi()
    tasks_list = []
    tasks_list.append(dict(action=dict(module=module, args=args)))
    run_ansible.runansible(host,tasks_list)

def run(value):
    print("进入ansible处理模块：")
    for i in value:
        module_content = i['module']
        parameter_content = i['parameter']
        group_content = i['group']
        print("==========================执行ansible模块=========================")
        print("group:%s\nmodule=%s\nparameter=%s"%(group_content,module_content,parameter_content))
        ansible_shll(host=group_content,module=module_content,args=parameter_content)